package com.homedo.odin.solution.controller.pc;

import com.homedo.core.common.base.controller.BaseController;
import com.homedo.core.common.base.dto.ResultData;
import com.homedo.odin.solution.contract.pc.PayCallBackResponseBean;
import com.homedo.odin.solution.contract.pc.PaymentResponseBean;
import com.homedo.odin.solution.contract.pc.UserOrderResponseBean;
import com.homedo.odin.solution.contract.pc.UserPayOrderRequestBean;
import com.homedo.odin.solution.contract.pc.UserPayRequestBean;
import com.homedo.odin.solution.model.base.MReturn;
import com.homedo.odin.solution.service.bizservice.pc.PayBizService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import java.math.BigDecimal;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: zhaoxudong
 * @date: 2018/4/11 16:35
 * @Description:
 */
@Api(description = "支付", tags = {"Pay"}, produces = MediaType.APPLICATION_JSON_VALUE)
@RestController
@RequestMapping("/v1/pc/pay")
public class PayController extends BaseController<PayBizService> {

    @ApiOperation(value = "PC_支付回调")
    @PostMapping("/callback")
    public MReturn<Long> payCallBack(@RequestParam(value = "IsVerify", required = false) Boolean IsVerify,
            @RequestParam(value = "Amount", required = false) BigDecimal Amount,
            @RequestParam(value = "OutTradeNo", required = false) String OutTradeNo,
            @RequestParam(value = "TradeNo", required = false) String TradeNo,
            @RequestParam(value = "PayBackData", required = false) String PayBackData,
            @RequestParam(value = "OrderIds", required = false) String OrderIds) {
        return baseService.payCallBack(IsVerify, Amount, OutTradeNo, TradeNo, PayBackData, OrderIds);

    }

    @ApiOperation(value = "PC_支付回调", response = PayCallBackResponseBean.class)
    @GetMapping("/pc/callback")
    public ResultData pcPayCallBack(@ApiParam(value = "用户id", required = true) @RequestParam("uid") Integer uid,
            @ApiParam(value = "订单流水号", required = true) @RequestParam("tradeNo") String tradeNo) {
        return baseService.pcPayCallBack(uid, tradeNo);
    }

    @ApiOperation(value = "PC_支付宝支付", response = PaymentResponseBean.class)
    @PostMapping("/alipay")
    public ResultData aliPay(UserPayRequestBean userPayRequestBean) {
        return baseService.aliPay(userPayRequestBean);
    }

    @ApiOperation(value = "PC_银联支付B2C", response = PaymentResponseBean.class)
    @PostMapping("/unionPay/b2c")
    public ResultData unionPayB2C(UserPayRequestBean userPayRequestBean) {
        return baseService.unionPayB2C(userPayRequestBean);
    }

    @ApiOperation(value = "PC_银联支付B2B", response = PaymentResponseBean.class)
    @PostMapping("/unionPay/b2b")
    public ResultData unionPayB2B(UserPayRequestBean userPayRequestBean) {
        return baseService.unionPayB2B(userPayRequestBean);
    }

    @ApiOperation(value = "PC_微信支付", response = PaymentResponseBean.class)
    @PostMapping("/wxPay")
    public ResultData wxPay(UserPayRequestBean userPayRequestBean) {
        return baseService.wxPay(userPayRequestBean);
    }

    @PostMapping("/payorder")
    @ApiOperation(value = "PC_生成支付订单", response = UserOrderResponseBean.class)
    public ResultData addPayOrder(@RequestBody UserPayOrderRequestBean payOrderRequestBean) {
        return baseService.addPayOrder(payOrderRequestBean);
    }
}
